博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
评论列表显示及排序,个人中心显示
阅读量:4618 次
发布时间:2019-06-09

本文共 1973 字,大约阅读时间需要 6 分钟。

  1. 显示所有评论
    {% for foo in ques.comments %}
    {
    % endblock %}
  2. 所有评论排序
    uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc))
    question=db.relationship('Question',backref=db.backref('comments',order_by=create_time.desc))
  3. 显示评论条数
    {
    { ques.comments|length }}

    评论:({
    { ques.comments|length }})

  4. 完成个人中心

1.个人中心的页面布局(html文件及相应的样式文件)

2.定义视图函数def usercenter(user_id):

3.向前端页面传递参数

4.页面显示相应数据

发布的全部问答

发布的全部评论

个人信息

5.各个页面链接到个人中心

@app.route('/usercenter/
')@loginFirstdef usercenter(user_id): user=User.query.filter(User.id==user_id).first() context={ 'username':user.username, 'questions':user.question, 'comments':user.comments } return render_template('usercenter.html',**context)
{% extends 'base.html'%} {% block title %}个人中心{% endblock %} {% block main%} 
{% endblock %}

转载于:https://www.cnblogs.com/yybx/p/8026524.html

你可能感兴趣的文章
excel 合并单元格
查看>>
iOS设计模式简介
查看>>
c# 扩展方法 奇思妙用 高级篇 九:OrderBy(string propertyName, bool desc)
查看>>
C语言中的地址传递(传指针,传递给形参的指针仍然是实参指针的一份拷贝)
查看>>
redis缓存数据库及Python操作redis
查看>>
opencms忘记Admin用户登录密码解决方案
查看>>
forms组件
查看>>
create-react-app 配置sass
查看>>
02_关系数据库
查看>>
在win7电脑中如何查看运行进程的PID标识符
查看>>
[Vue] vue-cli3.0安装
查看>>
C++学习之字符串
查看>>
图像化列表
查看>>
2014年10月9日——语言基础2
查看>>
How to Create Modifiers Using the API QP_MODIFIERS_PUB.PROCESS_MODIFIERS
查看>>
待飞笔记(第一天 )
查看>>
解惑好文:移动端H5页面高清多屏适配方案
查看>>
traefik添加多证书
查看>>
忽略UserInterfaceState.xcuserstate
查看>>
ReactNative--Flexbox布局
查看>>